
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>排序算法 · Aivin开发笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Aivin">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-local-video/video-js.min.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../styles/website.css">
        
    

        
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="查找算法.html" />
    
    
    <link rel="prev" href="算法术语.html" />
    

    
        <link rel="shortcut icon" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
        <link rel="bookmark" href='../../assets/images/favicon.ico' type="image/x-icon">
    
    
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    首页
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../doc/常用网站.html">
            
                <a href="../doc/常用网站.html">
            
                    
                    常用网站
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../常用软件/常用软件和框架.html">
            
                <a href="../常用软件/常用软件和框架.html">
            
                    
                    常用软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../doc/开发规范.html">
            
                <a href="../doc/开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../doc/开源软件.html">
            
                <a href="../doc/开源软件.html">
            
                    
                    开源软件和框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../doc/Android常用代码.html">
            
                <a href="../doc/Android常用代码.html">
            
                    
                    Android常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../源码阅读/源码阅读配置.html">
            
                <a href="../源码阅读/源码阅读配置.html">
            
                    
                    源码阅读
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../源码阅读/其他框架源码.html">
            
                <a href="../源码阅读/其他框架源码.html">
            
                    
                    其他框架源码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../产品经理/产品经理.html">
            
                <a href="../产品经理/产品经理.html">
            
                    
                    产品经理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../设计模式/设计模式.html">
            
                <a href="../设计模式/设计模式.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../设计模式/模式详解.html">
            
                <a href="../设计模式/模式详解.html">
            
                    
                    模式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../设计模式/mvc等.html">
            
                <a href="../设计模式/mvc等.html">
            
                    
                    mvc等
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    基本算法
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../数据结构/常用数据结构.html">
            
                <a href="../数据结构/常用数据结构.html">
            
                    
                    常用数据结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="算法术语.html">
            
                <a href="算法术语.html">
            
                    
                    算法术语
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10.3" data-path="排序算法.html">
            
                <a href="排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="查找算法.html">
            
                <a href="查找算法.html">
            
                    
                    查找算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="大数相加.html">
            
                <a href="大数相加.html">
            
                    
                    大数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="集合的所有子集.html">
            
                <a href="集合的所有子集.html">
            
                    
                    获得集合的所有子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="扫描线种子填充算法.html">
            
                <a href="扫描线种子填充算法.html">
            
                    
                    扫描线种子填充算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="其他算法.html">
            
                <a href="其他算法.html">
            
                    
                    其他算法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    Java部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../java基础/原码补码反码.html">
            
                <a href="../java基础/原码补码反码.html">
            
                    
                    原码补码反码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../java基础/java常用代码.html">
            
                <a href="../java基础/java常用代码.html">
            
                    
                    java常用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../java基础/JVM详解.html">
            
                <a href="../java基础/JVM详解.html">
            
                    
                    JVM详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../java基础/类加载机制.html">
            
                <a href="../java基础/类加载机制.html">
            
                    
                    类加载机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../java基础/内存模型.html">
            
                <a href="../java基础/内存模型.html">
            
                    
                    内存模型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.6" data-path="../java基础/GC机制.html">
            
                <a href="../java基础/GC机制.html">
            
                    
                    GC机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.7" data-path="../java基础/对象内存布局.html">
            
                <a href="../java基础/对象内存布局.html">
            
                    
                    对象内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.8" data-path="../java基础/继承多态.html">
            
                <a href="../java基础/继承多态.html">
            
                    
                    继承和多态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.9" data-path="../java基础/相等判断.html">
            
                <a href="../java基础/相等判断.html">
            
                    
                    相等判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.10" data-path="../java基础/Java容器类.html">
            
                <a href="../java基础/Java容器类.html">
            
                    
                    Java容器类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.11" data-path="../java基础/Java枚举.html">
            
                <a href="../java基础/Java枚举.html">
            
                    
                    Java枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.12" data-path="../java基础/自定义异常.html">
            
                <a href="../java基础/自定义异常.html">
            
                    
                    自定义异常
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.13" data-path="../java基础/深度拷贝.html">
            
                <a href="../java基础/深度拷贝.html">
            
                    
                    深度拷贝
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.14" data-path="../java基础/泛型详解.html">
            
                <a href="../java基础/泛型详解.html">
            
                    
                    泛型详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.15" data-path="../java基础/线程详解.html">
            
                <a href="../java基础/线程详解.html">
            
                    
                    线程详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.16" data-path="../java基础/java注解.html">
            
                <a href="../java基础/java注解.html">
            
                    
                    注解详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.17" data-path="../java基础/数据解析.html">
            
                <a href="../java基础/数据解析.html">
            
                    
                    数据解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.18" data-path="../java基础/java8新特性.html">
            
                <a href="../java基础/java8新特性.html">
            
                    
                    Java8新特性
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../android基础/基础控件使用.html">
            
                <a href="../android基础/基础控件使用.html">
            
                    
                    基础控件使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../android基础/android零散知识.html">
            
                <a href="../android基础/android零散知识.html">
            
                    
                    Android零散知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../android基础/android坐标体系.html">
            
                <a href="../android基础/android坐标体系.html">
            
                    
                    Android坐标体系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../android基础/APP的启动流程.html">
            
                <a href="../android基础/APP的启动流程.html">
            
                    
                    APP启动流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../android基础/View加载流程.html">
            
                <a href="../android基础/View加载流程.html">
            
                    
                    View加载流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../android基础/事件分发机制.html">
            
                <a href="../android基础/事件分发机制.html">
            
                    
                    事件分发机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.7" data-path="../android基础/控件绘制流程.html">
            
                <a href="../android基础/控件绘制流程.html">
            
                    
                    控件绘制流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.8" data-path="../android基础/常用shape.html">
            
                <a href="../android基础/常用shape.html">
            
                    
                    常用shape
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.9" data-path="../android基础/进程通信.html">
            
                <a href="../android基础/进程通信.html">
            
                    
                    进程通信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.10" data-path="../通信方式/通信方式详解.html">
            
                <a href="../通信方式/通信方式详解.html">
            
                    
                    通信方式详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.11" data-path="../android基础/Binder详解.html">
            
                <a href="../android基础/Binder详解.html">
            
                    
                    Binder详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.12" data-path="../android基础/Handler详解.html">
            
                <a href="../android基础/Handler详解.html">
            
                    
                    Handle详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.13" data-path="../android基础/Fragment详解.html">
            
                <a href="../android基础/Fragment详解.html">
            
                    
                    Fragment详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.14" data-path="../android基础/Activity详解.html">
            
                <a href="../android基础/Activity详解.html">
            
                    
                    Activity详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.15" data-path="../android基础/BroadcastReceiver.html">
            
                <a href="../android基础/BroadcastReceiver.html">
            
                    
                    BroadcastReceiver详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.16" data-path="../android基础/Service服务.html">
            
                <a href="../android基础/Service服务.html">
            
                    
                    Service详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.17" data-path="../android基础/动画详解.html">
            
                <a href="../android基础/动画详解.html">
            
                    
                    动画详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.18" data-path="../android基础/屏幕刷新机制.html">
            
                <a href="../android基础/屏幕刷新机制.html">
            
                    
                    屏幕刷新机制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.19" data-path="../android基础/屏幕适配.html">
            
                <a href="../android基础/屏幕适配.html">
            
                    
                    屏幕适配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.20" data-path="../android基础/图片加载详解.html">
            
                <a href="../android基础/图片加载详解.html">
            
                    
                    图片加载详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.21" data-path="../android基础/WebView详解.html">
            
                <a href="../android基础/WebView详解.html">
            
                    
                    WebView详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.22" data-path="../android基础/沉浸式.html">
            
                <a href="../android基础/沉浸式.html">
            
                    
                    沉浸式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.23" data-path="../android基础/相机模块.html">
            
                <a href="../android基础/相机模块.html">
            
                    
                    相机模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.24" data-path="../android基础/地图模块.html">
            
                <a href="../android基础/地图模块.html">
            
                    
                    地图模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.25" data-path="../android基础/Androidstudio插件开发.html">
            
                <a href="../android基础/Androidstudio插件开发.html">
            
                    
                    Androidstudio插件开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.26" data-path="../android基础/Apk插件化开发.html">
            
                <a href="../android基础/Apk插件化开发.html">
            
                    
                    Apk插件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.27" data-path="../android基础/App组件化开发.html">
            
                <a href="../android基础/App组件化开发.html">
            
                    
                    App组件化开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.28" data-path="../android基础/sdk开发.html">
            
                <a href="../android基础/sdk开发.html">
            
                    
                    sdk开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.29" data-path="../android基础/APP优化.html">
            
                <a href="../android基础/APP优化.html">
            
                    
                    APP优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.30" data-path="../android基础/项目参数配置.html">
            
                <a href="../android基础/项目参数配置.html">
            
                    
                    项目参数配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.31" data-path="../android基础/App发布.html">
            
                <a href="../android基础/App发布.html">
            
                    
                    App发布
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.32" data-path="../android基础/Android外挂.html">
            
                <a href="../android基础/Android外挂.html">
            
                    
                    Android外挂
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.33" data-path="../android基础/Android字节码插桩.html">
            
                <a href="../android基础/Android字节码插桩.html">
            
                    
                    Android字节码插桩
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.34" data-path="../android基础/智能家居.html">
            
                <a href="../android基础/智能家居.html">
            
                    
                    智能家居
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../python/python基础.html">
            
                <a href="../python/python基础.html">
            
                    
                    python基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../python/python爬虫.html">
            
                <a href="../python/python爬虫.html">
            
                    
                    python爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../gradle/Groovy.html">
            
                <a href="../gradle/Groovy.html">
            
                    
                    Groovy
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../kotlin/kotlin部分.html">
            
                <a href="../kotlin/kotlin部分.html">
            
                    
                    kotlin部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../flutter/flutter部分.html">
            
                <a href="../flutter/flutter部分.html">
            
                    
                    flutter部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    native部分
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../native/Linux.html">
            
                <a href="../native/Linux.html">
            
                    
                    Linux
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../native/ccpp.html">
            
                <a href="../native/ccpp.html">
            
                    
                    cCpp
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../native/NDK.html">
            
                <a href="../native/NDK.html">
            
                    
                    NDK
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../native/系统编译剪裁.html">
            
                <a href="../native/系统编译剪裁.html">
            
                    
                    系统编译剪裁
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.5" data-path="../native/音视频.html">
            
                <a href="../native/音视频.html">
            
                    
                    音视频
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.6" data-path="../native/音视频第三方库.html">
            
                <a href="../native/音视频第三方库.html">
            
                    
                    音视频第三方库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.7" data-path="../native/相关代码.html">
            
                <a href="../native/相关代码.html">
            
                    
                    相关代码
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../server/服务器部分.html">
            
                <a href="../server/服务器部分.html">
            
                    
                    服务器部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../webDev/web部分.html">
            
                <a href="../webDev/web部分.html">
            
                    
                    web部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="../人工智能/人工智能相关概念.html">
            
                <a href="../人工智能/人工智能相关概念.html">
            
                    
                    人工智能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="../面试真题/极飞.html">
            
                <a href="../面试真题/极飞.html">
            
                    
                    面试真题
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >排序算法</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><li><span class="title-icon "></span><a href="#&#x6392;&#x5E8F;&#x7B97;&#x6CD5;"><b>1. </b>&#x6392;&#x5E8F;&#x7B97;&#x6CD5;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5192;&#x6CE1;&#x6392;&#x5E8F;"><b>1.1. </b>&#x5192;&#x6CE1;&#x6392;&#x5E8F;</a></li><li><span class="title-icon "></span><a href="#&#x5F52;&#x5E76;&#x6392;&#x5E8F;-&#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;"><b>1.2. </b>&#x5F52;&#x5E76;&#x6392;&#x5E8F; &#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;</a></li><ul><li><span class="title-icon "></span><a href="#&#x9012;&#x5F52;&#x5206;"><b>1.2.1. </b>&#x9012;&#x5F52;&#x201C;&#x5206;&#x201D;</a></li><li><span class="title-icon "></span><a href="#&#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x5408;"><b>1.2.2. </b>&#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x201C;&#x5408;&#x201D;</a></li><li><span class="title-icon "></span><a href="#&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;"><b>1.2.3. </b>&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;</a></li></ul><li><span class="title-icon "></span><a href="#&#x5FEB;&#x901F;&#x6392;&#x5E8F;"><b>1.3. </b>&#x5FEB;&#x901F;&#x6392;&#x5E8F;</a></li><ul><li><span class="title-icon "></span><a href="#&#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;"><b>1.3.1. </b>&#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;</a></li></ul><li><span class="title-icon "></span><a href="#&#x9009;&#x62E9;&#x6392;&#x5E8F;"><b>1.4. </b>&#x9009;&#x62E9;&#x6392;&#x5E8F;</a></li><ul><li><span class="title-icon "></span><a href="#&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;"><b>1.4.1. </b>&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;</a></li></ul></ul></ul></div><a href="#&#x6392;&#x5E8F;&#x7B97;&#x6CD5;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="&#x6392;&#x5E8F;&#x7B97;&#x6CD5;"><a name="&#x6392;&#x5E8F;&#x7B97;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x6392;&#x5E8F;&#x7B97;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1. &#x6392;&#x5E8F;&#x7B97;&#x6CD5;</h1>
<h2 id="&#x5192;&#x6CE1;&#x6392;&#x5E8F;"><a name="&#x5192;&#x6CE1;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x5192;&#x6CE1;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1. &#x5192;&#x6CE1;&#x6392;&#x5E8F;</h2>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201802051441_osChina_%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F.gif" alt=""></p>
<pre><code class="lang-text">&#x6838;&#x5FC3;&#x601D;&#x60F3;&#x662F;&quot;&#x5192;&#x6CE1;&quot;&#x3002;
&#x6700;&#x540E;&#x7684;&#x6548;&#x679C;&#x662F;&#x7B2C;&#x4E00;&#x4E2A;&#x6700;&#x5C0F;&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x6700;&#x5927;&#xFF0C;&#x6C89;&#x5728;&#x6700;&#x4E0B;&#x3002;
&#x4E00;&#x6B21;&#x6BD4;&#x8F83; &#x53EF;&#x4EE5;&#x8BA9;&#x6570;&#x503C;&#x4E2D;&#x6700;&#x5C0F;&#x7684;&#x90A3;&#x4E2A;&#x503C;&#x5192;&#x51FA;&#x6765;&#x3002; 
&#x7136;&#x540E;&#x4F9D;&#x6B21;&#x6BD4;&#x8F83;&#xFF0C;&#x76F4;&#x5230;&#x5B8C;&#x6210;&#x3002;

/**
 * int[] array = { 7, 3, 10, 0, 6 , 0 ,-56 };
 * &#x5192;&#x6CE1;&#x6392;&#x5E8F;
 */
public static int[] sortBubble(int[] array){
    //&#x5916;&#x5C42;for &#x786E;&#x5B9A; &#x6392;&#x5E8F;&#x8D9F;&#x6B21;
    for ( int i = 0 ; i&lt; array.length-1 ;i++){
      //&#x5185;&#x5C42;for &#x786E;&#x5B9A;&#x5F53;&#x524D; &#x8D9F;&#x6B21; &#x9700;&#x8981;&#x6BD4;&#x8F83;&#x591A;&#x5C11;&#x4E0B;
        for (int j= array.length-1   ;j &gt;  i ; j--)  {
          int temp;
          //&#x5C06;&#x5C0F;&#x7684;&#x503C;&#x5F80;&#x524D;&#x79FB;&#x52A8;
          if(array[j] &lt; array[i])  {
            temp= array[j];
            array[j]= array[i];
            array[i]= temp ;
          }
        }//
    }//
    return array;
}
</code></pre>
<h2 id="&#x5F52;&#x5E76;&#x6392;&#x5E8F;-&#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;"><a name="&#x5F52;&#x5E76;&#x6392;&#x5E8F;-&#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x5F52;&#x5E76;&#x6392;&#x5E8F;-&#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2. &#x5F52;&#x5E76;&#x6392;&#x5E8F; &#x3001;&#x5408;&#x5E76;&#x6392;&#x5E8F;</h2>
<p>&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x4F53;&#x73B0;&#x4E86;&#x5206;&#x6CBB;&#x601D;&#x60F3;</p>
<h3 id="&#x9012;&#x5F52;&#x5206;"><a name="&#x9012;&#x5F52;&#x5206;" class="anchor-navigation-ex-anchor" href="#&#x9012;&#x5F52;&#x5206;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.1. &#x9012;&#x5F52;&#x201C;&#x5206;&#x201D;</h3>
<p>&#x9012;&#x5F52;&#x201C;&#x5206;&#x201D;&#x7684;&#x7EC8;&#x6B62;&#x6761;&#x4EF6;&#x662F;&#x201C;&#x53EA;&#x5269;&#x4E0B;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x201D; &#x3002; &#x56E0;&#x4E3A;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x8BA4;&#x4E3A;&#x5B83;&#x6709;&#x5E8F; &#x3002;</p>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803280933_osChina_&#x5408;&#x5E76;&#x6392;&#x5E8F;.png" alt=""></p>
<h3 id="&#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x5408;"><a name="&#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x5408;" class="anchor-navigation-ex-anchor" href="#&#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x5408;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.2. &#x6709;&#x5E8F;&#x5143;&#x7D20;&#x7684;&#x201C;&#x5408;&#x201D;</h3>
<p>&#x5148;&#x6BD4;&#x4E00;&#x4E0B; A&#x6307;&#x9488; &#x548C; B&#x6307;&#x9488; &#x6307;&#x5411;&#x7684;&#x4E24;&#x4E2A;&#x5143;&#x7D20;&#x8C01;&#x6BD4;&#x8F83;&#x5C0F;&#x4E00;&#x70B9;&#xFF0C;&#x7136;&#x540E;&#x628A;&#x6BD4;&#x8F83;&#x5C0F;&#x7684;&#x5143;&#x7D20;&#xFF08;&#x6B64;&#x65F6;&#x5047;&#x8BBE;A&#x6307;&#x9488;&#x6307;&#x5411;&#x7684;&#x5143;&#x7D20;&#x5C0F;&#xFF09;&#x653E;&#x5230;C&#x6307;&#x9488;&#x6307;&#x7684;&#x4F4D;&#x7F6E;&#x4E0A;&#x3002;   A&#x5F80;&#x524D;&#x632A;&#xFF0C;C &#x5F80;&#x524D;&#x632A; &#x3002;&#x7136;&#x540E;&#x7EE7;&#x7EED;&#x6BD4;&#x8F83;A&#x6307;&#x9488;&#x548C;B&#x6307;&#x9488;&#x7684;&#x4E24;&#x4E2A;&#x5143;&#x7D20;&#x3002;
<img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803280934_osChina_&#x5408;&#x5E76;&#x6392;&#x5E8F;2.png" alt=""></p>
<h3 id="&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;"><a name="&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;" class="anchor-navigation-ex-anchor" href="#&#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>1.2.3. &#x5408;&#x5E76;&#x6392;&#x5E8F;&#x7F3A;&#x70B9;</h3>
<p>&#x9700;&#x8981;&#x989D;&#x5916;&#x7684;&#x7A7A;&#x95F4;&#x8F85;&#x52A9;&#x3002;</p>
<pre><code class="lang-text">/**
 * &#x5F52;&#x5E76; &#x6392;&#x5E8F;&#x3002; &#x5347;&#x5E8F;
 */
public static void mergeSort(int[]array , int start , int end){
  if(start&gt;=end){
    //&#x9012;&#x5F52;&#x7EC8;&#x6B62;&#x6761;&#x4EF6;
    return ;
  }else{
    int mid = (start + end )/2 ;
    //&#x9012;&#x5F52;&#x5904;&#x7406;&#x5DE6;&#x8FB9;
    mergeSort(array , start ,mid);
    //&#x9012;&#x5F52;&#x5904;&#x7406;&#x53F3;&#x8FB9;
    mergeSort(array ,mid+1   ,end);
    //&#x5408;&#x5E76; &#x6392;&#x5E8F;&#x597D;&#x7684;&#x5DE6;&#x53F3;
    mergeAction(array ,start ,mid  ,end);
  }
}

public static void mergeAction(int[]arr ,int start ,int mid , int end ){
    //&#x8F85;&#x52A9;&#x6570;&#x7EC4;&#x7A7A;&#x95F4;  &#x5E76;&#x4E0D;&#x662F; int[] tempArr = new int[arr.lengh]
    int[] tempArr = new int[end - start + 1];
    //&#x5DE6;&#x6570;&#x7EC4;&#x7684;&#x4E0B;&#x6807;
    int ptrA = start;
    //&#x53F3;&#x6570;&#x7EC4;&#x7684;&#x4E0B;&#x6807;
    int ptrB = mid +1;
    //&#x8F85;&#x52A9;&#x6570;&#x7EC4;&#x7684;&#x4E0B;&#x6807;
    int ptrC=0;

    //&#x5FAA;&#x73AF;&#x6BD4;&#x8F83;&#xFF0C;&#x76F4;&#x81F3;&#x6709;&#x4E00;&#x4E2A;&#x533A;&#x95F4;&#x88AB;&#x53D6;&#x5B8C;
    while (ptrA &lt;= mid &amp;&amp; ptrB &lt;= end) {
        tempArr[ptrC++] = arr[ptrA] &lt;= arr[ptrB] ?
                arr[ptrA++] : arr[ptrB++];
    }

    //&#x5C06;&#x5DE6;&#x8FB9;&#x672A;&#x5B8C;&#x6210;&#x7684;&#x6574;&#x4F53;&#x590D;&#x5236;
    while(ptrA &lt;= mid){
        tempArr[ptrC++] =arr[ptrA++];
    }

    //&#x5C06;&#x53F3;&#x8FB9;&#x672A;&#x5B8C;&#x6210;&#x7684;&#x6574;&#x4F53;&#x590D;&#x5236;
    while(ptrB &lt;=  end){
        tempArr[ptrC++] =arr[ptrB++];
    }

    //&#x5C06;&#x5408;&#x5E76;&#x597D;&#x7684;&#x6570;&#x636E;&#x8D4B;&#x503C;&#x7ED9;&#x539F;&#x6570;&#x7EC4;
    for(int i=0;i&lt;tempArr.length;i++){
        arr[start + i] = tempArr[i];
    }
}

//&#x6D4B;&#x8BD5;
int[] arr = {4,3,6,2,7,1,5};
System.out.println(Arrays.toString(arr));
mergeSort(arr , 0 ,arr.length-1);
System.out.println(Arrays.toString(arr));
</code></pre>
<h2 id="&#x5FEB;&#x901F;&#x6392;&#x5E8F;"><a name="&#x5FEB;&#x901F;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x5FEB;&#x901F;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3. &#x5FEB;&#x901F;&#x6392;&#x5E8F;</h2>
<pre><code class="lang-text">&#x4E4B;&#x6240;&#x4EE5;&#x8BF4;&#x5B83;&#x662F;&#x5FEB;&#x901F;&#x7684;&#x539F;&#x56E0;&#xFF0C;&#x4E0D;&#x662F;&#x56E0;&#x4E3A;&#x5B83;&#x6BD4;&#x5176;&#x4ED6;&#x7684;&#x6392;&#x5E8F;&#x7B97;&#x6CD5;&#x90FD;&#x8981;&#x5FEB;&#x3002;
&#x800C;&#x662F;&#x4ECE;&#x5B9E;&#x8DF5;&#x4E2D;&#x8BC1;&#x660E;&#x4E86;&#x5FEB;&#x901F;&#x6392;&#x5E8F;&#x5728;&#x5E73;&#x5747;&#x6027;&#x80FD;&#x4E0A;&#x7684;&#x786E;&#x662F;&#x6BD4;&#x5176;&#x4ED6;&#x7B97;&#x6CD5;&#x8981;&#x5FEB;&#x4E00;&#x4E9B; &#x3002;

&#x627E;&#x4E00;&#x4E2A;&#x57FA;&#x51C6;&#x5143;&#x7D20;&#xFF0C;&#x5BF9;&#x6570;&#x7EC4;&#x8FDB;&#x884C;&#x8C03;&#x6574;&#xFF0C;
&#x8C03;&#x6574;&#x7684;&#x6807;&#x51C6;&#x662F;&#xFF0C;&#x8FD9;&#x4E2A;&#x57FA;&#x51C6;&#x5143;&#x7D20;&#x7684;&#x5DE6;&#x8FB9;&#x5B58;&#x653E;&#x7684;&#x90FD;&#x662F;&#x6BD4;&#x8FD9;&#x4E2A;&#x5143;&#x7D20;&#x5C0F;&#x7684;&#xFF0C;&#x53F3;&#x8FB9;&#x90FD;&#x662F;&#x6BD4;&#x8FD9;&#x4E2A;&#x5143;&#x7D20;&#x5927;&#x7684;&#x3002;
&#x7136;&#x540E;&#x5206;&#x800C;&#x6CBB;&#x4E4B;&#xFF0C;&#x5BF9;&#x5DE6;&#x53F3;&#x4E24;&#x8FB9;&#x7684;&#x5B50;&#x6570;&#x7EC4;&#x5229;&#x7528;&#x540C;&#x6837;&#x7684;&#x89C4;&#x5219;&#x8C03;&#x6574;&#xFF0C;&#x8C03;&#x6574;&#x5230;&#x6BCF;&#x4E00;&#x4E2A;&#x5B50;&#x6570;&#x7EC4;&#x4E2D;&#x90FD;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x65F6;&#x7ED3;&#x675F;&#x3002;
&#xFF08;&#x5FEB;&#x6392;&#x4F53;&#x73B0;&#x4E86;&#x5206;&#x800C;&#x6CBB;&#x4E4B;&#x7684;&#x601D;&#x60F3;&#xFF0C;&#x4E00;&#x6B65;&#x6B65;&#x5730;&#x628A;&#x95EE;&#x9898;&#x53D8;&#x5C0F;&#xFF0C;&#x6700;&#x7EC8;&#x89E3;&#x51B3;&#x3002;&#xFF09;
</code></pre>
<h3 id="&#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;"><a name="&#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;" class="anchor-navigation-ex-anchor" href="#&#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;"><i class="fa fa-link" aria-hidden="true"></i></a>1.3.1. &#x5FEB;&#x6392;&#x7684;&#x7406;&#x89E3;</h3>
<p>&#x5FEB;&#x6392;&#x6709;&#x591A;&#x79CD;&#x7406;&#x89E3;&#x89D2;&#x5EA6;&#xFF0C;&#x4E2A;&#x4EBA;&#x89C9;&#x5F97;&#x4ECE;&#x201C;&#x6316;&#x5751;&#x586B;&#x5751;&#x201D;&#x7684;&#x89D2;&#x5EA6;&#x6BD4;&#x8F83;&#x5BB9;&#x6613;&#x7406;&#x89E3;&#x3002;</p>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201802061409_osChina_&#x5FEB;&#x901F;&#x6392;&#x5E8F;&#x793A;&#x610F;&#x56FE;.png" alt=""></p>
<pre><code class="lang-text">/**&#x6700;&#x57FA;&#x7840;&#x7684; &#x5FEB;&#x901F;&#x6392;&#x5E8F;*/
public void quickSort(int[] array, int left , int right){
  if(left &lt; right){
    //&#x627E;&#x5206;&#x6CBB;&#x7684;&#x4E2D;&#x7EBF;&#xFF0C;
    int location=  getDivideLocation(  array , left , right) ;
    //&#x9012;&#x5F52;&#x6392;&#x5E8F;&#x4E2D;&#x503C;&#x5DE6;&#x53F3;&#x7684;&#x503C;
    quickSort(array, left, location-1) ;
    quickSort(array, location+1, right);
  }
}

/**
 * &#x4E00;&#x8D9F;&#x6392;&#x5E8F;&#x3002;&#x5C06;&#x4E2D;&#x4F4D;&#x503C;&#x79FB;&#x52A8;&#x5230;&#x76EE;&#x6807;&#x4F4D;&#x7F6E;&#x3002;
 * @return &#x4E2D;&#x4F4D;&#x503C;&#x7684;&#x4E0B;&#x6807;
 */
public int getDivideLocation(int[] array, int left , int right){
  //&#x6316;&#x7B2C;&#x4E00;&#x4E2A;&#x5751;&#xFF0C;&#x5C06;&#x503C;&#x4FDD;&#x5B58;&#x5230;&#x4E34;&#x65F6;&#x53D8;&#x91CF;
  int base = array[left];
  // &#x5FAA;&#x73AF;&#x6316;&#x5751;&#x586B;&#x5751; ,&#x505C;&#x6B62;&#x6761;&#x4EF6;&#xFF1A; left=right
  while(left&lt; right){
    //&#x4ECE;&#x53F3;&#x8FB9;&#x5F00;&#x59CB;&#x5BFB;&#x627E;&#x5751;&#x503C;
    while (left &lt; right &amp;&amp; array[right] &gt;= base){
      right-- ;
    }

    //&#x627E;&#x5230;&#x5751;&#x503C;&#xFF0C;&#x586B;&#x5751;
    array[left] = array[right] ;

    //&#x4ECE;&#x5DE6;&#x8FB9;&#x5F00;&#x59CB;&#x5BFB;&#x627E;&#x5751;&#x503C;
    while (left &lt; right &amp;&amp; array[left] &lt;= base){
      left++ ;
    }
    //&#x627E;&#x5230;&#x5751;&#x503C;  &#xFF0C;&#x586B;&#x5751;
    array[right]= array[left] ;
  }

  //&#x6B64;&#x65F6;&#xFF0C; left==right , &#x786E;&#x5B9A;&#x4E2D;&#x4F4D;&#x503C;&#x7684;&#x4F4D;&#x7F6E;
  array[left] = base ;
  return left ;
}

//&#x6D4B;&#x8BD5;
int[]array = ...;
quickSort.quickSort(array, 0, array.length-1) ;
</code></pre>
<h2 id="&#x9009;&#x62E9;&#x6392;&#x5E8F;"><a name="&#x9009;&#x62E9;&#x6392;&#x5E8F;" class="anchor-navigation-ex-anchor" href="#&#x9009;&#x62E9;&#x6392;&#x5E8F;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4. &#x9009;&#x62E9;&#x6392;&#x5E8F;</h2>
<p>&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x7684;&#x601D;&#x60F3;&#xFF1A;&#x5C31;&#x662F;&#x4E0D;&#x65AD;&#x5730;&#x4ECE;&#x672A;&#x6392;&#x5E8F;&#x7684;&#x5143;&#x7D20;&#x4E2D;&#x9009;&#x62E9;&#x6700;&#x5927;&#xFF08;&#x6216;&#x6700;&#x5C0F;&#xFF09;&#x7684;&#x5143;&#x7D20;&#x653E;&#x5165;&#x5DF2;&#x6392;&#x597D;&#x5E8F;&#x7684;&#x5143;&#x7D20;&#x96C6;&#x5408;&#x4E2D;&#xFF0C;&#x76F4;&#x5230;&#x672A;&#x6392;&#x5E8F;&#x4E2D;&#x4EC5;&#x5269;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x4E3A;&#x6B62; &#x3002;</p>
<p><del>&#x9009;&#x62E9;&#x6392;&#x5E8F; &#x548C;&#x5192;&#x6CE1;&#x6392;&#x5E8F;&#x6709;&#x70B9;&#x7C7B;&#x4F3C;&#xFF0C;&#x90FD;&#x662F;&#x5728;&#x4E00;&#x6B21;&#x6392;&#x5E8F;&#x540E;&#x628A;&#x6700;&#x5927;(&#x6700;&#x5C0F;)&#x7684;&#x5143;&#x7D20;&#x653E;&#x5230;&#x6700;&#x524D;&#x9762;&#x3002;&#x4F46;&#x662F;&#x8FC7;&#x7A0B;&#x4E0D;&#x540C;&#xFF0C;&#x5192;&#x6CE1;&#x6392;&#x5E8F;&#x662F;&#x901A;&#x8FC7;&#x76F8;&#x90BB;&#x7684;&#x6BD4;&#x8F83;&#x548C;&#x4EA4;&#x6362;&#x3002;&#x800C;&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x662F;&#x901A;&#x8FC7;&#x5BF9;&#x6574;&#x4F53;&#x7684;&#x9009;&#x62E9;&#x3002;</del> <br>  &#x9009;&#x62E9;&#x6392;&#x5E8F; &#x53EF;&#x4EE5;&#x770B;&#x6210; &#x5192;&#x6CE1;&#x6392;&#x5E8F; &#x7684;&#x4F18;&#x5316;&#xFF0C;&#x53EA;&#x6709;&#x5728;&#x786E;&#x5B9A;&#x4E86;&#x6700;&#x5C0F;&#x6570;&#x7684;&#x524D;&#x63D0;&#x4E0B;&#x624D;&#x8FDB;&#x884C;&#x4EA4;&#x6362;&#xFF0C;&#x5927;&#x5927;&#x51CF;&#x5C11;&#x4E86;&#x4EA4;&#x6362;&#x7684;&#x6B21;&#x6570;&#x3002;</p>
<p><img src="https://gitee.com/hnyer/filesOfGitbook/raw/master/files/201803271522_osChina_&#x9009;&#x62E9;&#x6392;&#x5E8F;.gif" alt=""></p>
<h3 id="&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;"><a name="&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;" class="anchor-navigation-ex-anchor" href="#&#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;"><i class="fa fa-link" aria-hidden="true"></i></a>1.4.1. &#x9009;&#x62E9;&#x6392;&#x5E8F;&#x5173;&#x952E;&#x70B9;</h3>
<pre><code class="lang-text">1&#x3001;&#x6709;&#x5E8F;&#x533A;&#x95F4;  &#x3001; &#x65E0;&#x5E8F;&#x533A;&#x95F4;
2&#x3001;&#x5982;&#x4F55;&#x9009;&#x51FA;&#x6700;&#x5927;&#xFF08;/&#x6700;&#x5C0F;&#xFF09;&#x5143;&#x7D20;
</code></pre>
<pre><code class="lang-text">/**
 *  &#x9009;&#x62E9;&#x6392;&#x5E8F;  &#x5347;&#x5E8F;
 */
public static int [] sortSelect(int [] array){
  int length = array.length;
  for(int i=0 ;i &lt;length-1 ; i++){
    int minPos= i ;
    //&#x4E00;&#x6B21;&#x6392;&#x5E8F;&#xFF0C;&#x9009;&#x51FA;&#x6700;&#x5C0F;&#x7684;&#x653E;&#x5230;&#x6570;&#x7EC4;&#x524D;&#x9762;
    for(int k=i+1 ; k&lt; length ; k++){
      if(array[minPos] &gt; array[k]){
        minPos=k ;
      }
    }

    //&#x5C06;&#x5F53;&#x524D;&#x8D9F;&#x6B21;&#x7684;&#x7ED3;&#x679C;&#x653E;&#x5230; &#x6709;&#x5E8F;&#x533A;&#x95F4;
    if(array[minPos] &lt; array[i]){
      int temp ;
      temp= array[minPos] ;
      array[minPos] = array[i];
      array[i] =temp;
    }
  }
  return array ;
}
</code></pre>
<footer class="page-footer"><span class="copyright">( no Copyright&#xFF0C;enjoy youself ! ) all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">The file was updated at :
2022-04-04 10:49:02
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="算法术语.html" class="navigation navigation-prev " aria-label="Previous page: 算法术语">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="查找算法.html" class="navigation navigation-next " aria-label="Next page: 查找算法">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"排序算法","level":"1.10.3","depth":2,"next":{"title":"查找算法","level":"1.10.4","depth":2,"path":"chinese/常用算法/查找算法.md","ref":"chinese/常用算法/查找算法.md","articles":[]},"previous":{"title":"算法术语","level":"1.10.2","depth":2,"path":"chinese/常用算法/算法术语.md","ref":"chinese/常用算法/算法术语.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","search-plus","todo","anchor-navigation-ex","copy-code-button","fontsettings","tbfed-pagefooter","local-video","splitter","expandable-chapters","favicon","theme-comscore","local-video"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"( no Copyright，enjoy youself ! )","modify_label":"The file was updated at :","modify_format":"YYYY-MM-DD HH:mm:ss"},"todo":{},"splitter":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"highlight":{},"anchor-navigation-ex":{"associatedWithSummary":true,"float":{"floatIcon":"fa fa-navicon","level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"mode":"float","multipleH1":true,"pageTop":{"level1Icon":"","level2Icon":"","level3Icon":"","showLevelIcon":false},"printLog":false,"showGoTop":true,"showLevel":true},"favicon":{"shortcut":"assets/images/favicon.ico","bookmark":"assets/images/favicon.ico"},"theme-comscore":{},"local-video":{},"copy-code-button":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"Aivin","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Aivin开发笔记","language":"zh-hans","gitbook":"*","description":"Aivin开发笔记"},"file":{"path":"chinese/常用算法/排序算法.md","mtime":"2022-04-04T02:49:02.901Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-04-04T03:47:09.782Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-local-video/video.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

